package me.ingxin.android.tools.app.drawer

import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import me.ingxin.android.tools.app.databinding.ItemPageHorizontalTxtBinding

/**
 * Created by ingxin on 2022/5/27
 */
class PageHorizontalAdapter: RecyclerView.Adapter<PageHorizontalAdapter.ViewHolder>() {


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder(
            ItemPageHorizontalTxtBinding.inflate(
                LayoutInflater.from(parent.context),
                parent,
                false
            )
        )
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.bind(position)
    }

    override fun getItemCount(): Int {
        return 10
    }

    class ViewHolder(private val binding: ItemPageHorizontalTxtBinding) :
        RecyclerView.ViewHolder(binding.root) {


        init {
            binding.tv.setOnClickListener {
                Toast.makeText(it.context, "点击水平数据${adapterPosition}", Toast.LENGTH_SHORT).show()
            }
        }


        fun bind(p: Int) {
            binding.tv.text = "水平数据$p"
        }
    }

}